<template>
    <mavon-editor ref=md :value="value" @imgAdd="$imgAdd" @save="save"></mavon-editor>
</template>

<script>
    import 'mavon-editor/dist/css/index.css'
    import { blogMdFileUpload } from '@/api/fileupload/blogMdFileUpload'
    export default {
        name: "index",
        props: {
            value: {
                type: String,
                default: ''
            }
        },
        methods: {
            // 绑定@imgAdd event
            async $imgAdd(pos, $file){
                var formdata = new FormData();
                formdata.append('file', $file);
                let data = await blogMdFileUpload(formdata);
                this.$refs.md.$img2Url(pos, data);
            },
            save(v) {
                this.$emit('save', v)
            }
        }
    }
</script>

<style scoped>

</style>